-
Notifications
You must be signed in to change notification settings - Fork 696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Increase HttpClientHandler.MaxConnectionsPerServer to 64 to improve PM UI performance in Visual Studio #4798
Conversation
Personally, I have no problem with you marking that issue as being fixed as well. If anyone from @NuGet/nuget-client disagrees, they should chime in :) |
@@ -48,6 +48,13 @@ private static HttpHandlerResourceV3 CreateResource(PackageSource packageSource) | |||
AutomaticDecompression = (DecompressionMethods.GZip | DecompressionMethods.Deflate) | |||
}; | |||
|
|||
#if IS_DESKTOP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If people set the MaxHTTPRequestPerSource explicitly we should always respect that.
Doesn't this break that in dotnet.exe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If customers have configured MaxHttpRequestsPerSource
then throttling requests is controlled by following code in both .NET
and .NET Framework
code paths. we don't change the value to 64
(which is new default).
NuGet.Client/src/NuGet.Core/NuGet.Protocol/HttpSource/HttpSourceResourceProvider.cs
Lines 46 to 49 in a56c42d
else if (source.PackageSource.MaxHttpRequestsPerSource > 0) | |
{ | |
throttle = SemaphoreSlimThrottle.CreateSemaphoreThrottle(source.PackageSource.MaxHttpRequestsPerSource); | |
} |
The only difference is, in .NET Framework
code path if customers configure MaxHttpRequestsPerSource
then above logic controls throttling requests and we also set HttpClientHandler.MaxConnectionsPerServer
to MaxHttpRequestsPerSource
value. The reason is customers may expect NuGet to send that many requests to a source in parallel but at the end because of the default MaxConnectionsPerServer
only 2
requests are sent. Whereas in .NET
code paths above logic controls throttling requests and we don't MaxConnectionsPerServer
because its default value is Int32.MaxValue
.
I disagree. If VS was hanging when making network calls, that needs to be fixed by not wating for the network to finish on the UI thread. So, it might have been fixed by #4739. If it wasn't, then the duration of the UI delay might be reduced by this PR, but it doesn't fix network calls being made on the UI thread. |
I actually agree with you :D I didn't read that issue in too much detail. It was actually a real hang, with UI freezes and all. |
@zivkan @nkolev92 I agree with both of you :). I am unable to reproduce this issue NuGet/Home#11638 even on the internal dogfooding version. Given that @jebriede fixed this UI delay in #4739, I would let him close NuGet/Home#11638 this issue as well. |
@kartheekp-ms The fix I made for #4739 fixed a specific code path from running on the UI thread that was rebuilding cache files on the file system. The fix was not expecting or attempting to resolve all issues where code paths originating from the PMUI were running on the UI thread because each such code path originates from different places. Any other occurrences will need to be addressed separately. |
I think the problem in NuGet/Home#11638 is that we don't understand what exact codepath no? |
c1855f3
to
5711e83
Compare
I noticed typos in the test names I added in this PR. Hence pushed a new commit updating the test names and added a comment to explain why discard is used to ignore a return value in one of the test cases. |
test/NuGet.Core.Tests/NuGet.Protocol.Tests/HttpSourceResourceProviderTests.cs
Outdated
Show resolved
Hide resolved
test/NuGet.Core.Tests/NuGet.Protocol.Tests/HttpSourceResourceProviderTests.cs
Outdated
Show resolved
Hide resolved
test/NuGet.Core.Tests/NuGet.Protocol.Tests/HttpSourceResourceProviderTests.cs
Outdated
Show resolved
Hide resolved
test/NuGet.Core.Tests/NuGet.Protocol.Tests/HttpHandlerResourceV3ProviderTests.cs
Outdated
Show resolved
Hide resolved
test/NuGet.Core.Tests/NuGet.Protocol.Tests/HttpHandlerResourceV3ProviderTests.cs
Outdated
Show resolved
Hide resolved
test/NuGet.Core.Tests/NuGet.Protocol.Tests/HttpHandlerResourceV3ProviderTests.cs
Outdated
Show resolved
Hide resolved
I have manually queued a PR build by updating the variable to run end to end/apex tests on VS 17.3. CI checks passed for this PR. I am planning to merge this PR today. |
Insert 6.4.0-rc.123 into rel/d17.4 on 11/07/2022 23:47:12 * tag '6.4.0.123': (60 commits) fix a logic error that caused AbandonedMutexException while executing migrations (release-6.4.x) (NuGet#4895) unblock source build failing due to fatal: transport 'file' not allowed error (NuGet#4867) (NuGet#4874) Signing: update to August 2022 CTL (NuGet#4791) (NuGet#4850) Merged PR 422933: Prefer BCL Directory create API over helper class (7.0.1xx-rc2) Fix empty combobox when package is not present in project file (NuGet#4844) (NuGet#4848) Fix component detection alert for microsoft.owin package (NuGet#4841) (NuGet#4845) Make release label RC, move to escrow mode Adds special case to include transitive origins in GetInstalledAndTransitivePackagesAsync API (NuGet#4824) Add longPathAware manifest to NuGet.Build.Tasks.Console (NuGet#4830) VsPackageInstallerServices should not post ProjectNotNominatedException faults (NuGet#4814) Skip test GetOrCreateAsync_WithUnhandledExceptionInPlugin_Throws (NuGet#4831) Improve OptProf pipeline job run names (NuGet#4825) Increase HttpClientHandler.MaxConnectionsPerServer to 64 to improve PM UI performance in Visual Studio (NuGet#4798) Suppress CA2213 warnings to unblock dev branch (NuGet#4823) Ensure IsVsOfflineFeed is calculated correctly on 64-bit machines (NuGet#4817) Add better handling of AggregateExceptions in static graph-based restore (NuGet#4809) Add Component Detection task into each pipeline (NuGet#4813) Localizes nuget.exe with default, embedded resource assembly lookup (NuGet#4773) Removes BrowseObjectBase class in NuGet Solution Explorer (NuGet#4807) Improve TryCreateContext (NuGet#4762) ...
Bug
Fixes: NuGet/Home#11923
Regression? Last working version:
Description
Thank you @mjolka for identifying this performance improvement and creating the linked issue. For context,
HttpClientHandler.MaxConnectionsPerServer
is by default2
in .NET framework but the default value in .NET Core isInt32.MaxValue
. Reference https://docs.microsoft.com/en-gb/archive/blogs/timomta/controlling-the-number-of-outgoing-connections-from-httpclient-net-core-or-full-framework. The performance improvements of Visual Studio PM UI mentioned in the linked issue description were great. Hence, in this PR I propose to increaseHttpClientHandler.MaxConnectionsPerServer
to64
in.NET Framework
code paths but don't change this property in.NET
code paths because of the default value i.e.,Int32.MaxValue
. NuGet.exe on Windows sets max connections limit per endpoint to 64. Hence, I used the same value64
in this PR. The proposed changes also allow customers to tweakHttpClientHandler.MaxConnectionsPerServer
by addingmaxHttpRequestsPerSource
in NuGet.Config file.I asked
.NET Networking team
if there would be any issues upgradingMaxConnectionsPerServer
value in .NET Framework code paths. The response received so far from the team seems to be positive https://github.com/orgs/dotnet/teams/ncl/discussions/1. Hence, I went ahead with the changes. Thanks to @drewgillies for taking the time to test a private build with this fix. He mentioned that this fix made a lot of difference to the usability and performance of PM UI in Visual Studio.I don't have numbers handy right now, but I noticed great performance improvements in Visual Studio solution restore scenario. I will run a quick test and post the results here.EDIT: I captured few metrics. This PR reduced OrchardCore VS Solution restore by 10 seconds.
dotnet restore (7.0.100-preview.6)
for OrchardCore solution in my local machine took32 seconds
. This number is close to VS solution restore scenario for defaultMaxConnectionsPerSever
proposed in this PR which is64
.PR Checklist
PR has a meaningful title
PR has a linked issue.
Described changes
Tests
Documentation